import request from '../utils/request'
// 获取所有权限列表
export const getAllRoles = type => {
  return request({
    url: 'rights/' + type
  })
}

// 获取角色列表
export const getRolesList = () => {
  return request({
    url: 'roles'
  })
}

// 角色授权
export const roleAuthorization = (id, rids) => {
  return request({
    url: 'roles/' + id + '/rights',
    method: 'POST',
    data: {
      rids: rids
    }
  })
}

// 删除角色指定权限
export const deleteRoleAuthorization = (id, rids) => {
  return request({
    url: 'roles/' + id + '/rights/' + rids,
    method: 'delete'
  })
}

// 删除角色
export const deleteRole = id => {
  return request({
    url: 'roles/' + id,
    method: 'delete'
  })
}

// 添加角色
export const addRole = data => {
  return request({
    url: 'roles',
    method: 'POST',
    data
  })
}

// 编辑角色
export const editRole = (data, id) => {
  return request({
    url: 'roles/' + id,
    method: 'PUT',
    data
  })
}
